;( function () {
	"use strict";
    var param_map = Result.getLocationParamObject();
    var global_param_map;
	
	$( function () {
		if(!ifUser()){
			return;
		}
		$("#tijiao").click(function(){
			bind();
		});
		
		
	}); 

	
	/**
	 * 修改绑定手机号
	 */
	function bind(){
		//进行验证
		var $form = $( "#form" );
 		$form.find("input").each( function () {
	    	$( this ).keydown( function () {
	        	if($( this ).hasClass('result-invalid')){
	           		$( this ).removeClass('result-invalid');
	           	}
	        } );
        } ); 
        
	 	if ( Result.validateForm( $form ) === true ) {
        	var params = Result.getFormData( $form, true );
        	var postParams =  {};
        	var reg = /^[A-Za-z0-9]{6,30}$/;      
        	if(!(reg.test(params.password))){
        		alert("请输入6-30个字符或数字");
        		$("#password").addClass("result-invalid");
        		return;
        	}
        	if(params.password != params.password1){
        		alert("两次输入的密码不一致");
        		$("#password1").addClass("result-invalid");
        		return;
        	}
        	postParams.old = params.old_password;
        	postParams.newPassword = params.password;
        	postParams.userId = USER.userId;
        	$.ajax(
                getAjaxOps('/user/modifyPwd', postParams)
            ).done(function (res) {
                if(res.resultCode == 0){
                	$("body").tips("修改成功");
					setTimeout(function(){
						window.history.go(-1);
					},1000);
                }else {
                	$("body").tips(res.data);
                }
            });
       	} 
	}
	
	
	
	

}( window ) );
